<!DOCTYPE html>
<html class="x-admin-sm">

{include file="common/static" /}
{include file="common/resources" /}
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">

                        <div class="layui-card-header">
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" id="city" placeholder="请输入城市" autocomplete="off" class="layui-input">
                            </div>
                            <button class="layui-btn" onclick="adds()">
                                <i class="layui-icon"></i>
                                添加
                            </button>
                        </div>
                        <div class="layui-card-body ">
                            <div class="layui-row">
                                {volist name="list" id="vo"}
                                    <div class="layui-col-md2"
                                         style="text-align: center;background-color: #71d5a1;margin: 20px;cursor:pointer;">

                                        <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" style="float: right"
                                                onclick="city_del({$vo.id})">
                                            移除
                                        </button>
                                        <span style="color: #FFFFFF"><h3>{$vo.citys}</h3></span>
                                    </div>
                                {/volist}
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </body>

<script>layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });


function adds(){
    $.ajax({
        type:"post",
        url: "{:url('index/citys/adds')}",
        data: {
            citys:$('#city').val()
        },
        success: function(data){
            console.log(data);
            toastr.error(data.msg);
            if(data.code == 100){
                setTimeout(function () {
                    layer.closeAll();
                    parent.location.reload();
                },1500);
            }
        }});
}

/*房型-删除*/
function city_del(id) {

    $.ajax({
        type:"post",
        url: "{:url('index/citys/deletes')}",
        data: {
            id:id
        },
        success: function(data){
            console.log(data);
            toastr.error(data.msg);
            if(data.code == 100){
                setTimeout(function () {
                    location.reload();
                },1000);
            }
        }});

}

</script>


</html>